﻿using System;
using System.Data.Common;
using System.Data;

namespace Bpms.Data
{
    /// <summary>
    /// 数据库提供相关接口
    /// </summary>
    public interface IDbProvider
    {
        /// <summary>
        ///  返回DbProviderFactory实例
        /// </summary>
        /// <returns></returns>
        DbProviderFactory Instance();

        /// <summary>
        /// 返回刚插入记录的自增ID值, 如不支持则为""
        /// </summary>
        /// <returns></returns>
        string GetLastIdSql();

        /// <summary>
        /// 创建SQL参数
        /// </summary>
        /// <param name="ParamName">参数名称</param>
        /// <param name="dbType">参数类型</param>
        /// <param name="size">参数大小</param>
        /// <returns></returns>
        DbParameter MakeParam(string ParamName, DbType dbType, Int32 size);

        /// <summary>
        /// 得到最后一个ID
        /// </summary>
        /// <param name="fieldName">字段名称</param>
        /// <param name="tableName">表名称</param>
        /// <param name="condition">查询条件</param>
        /// <returns></returns>
        int GetId(string fieldName, string tableName, string condition);
    }
}
